package com.java.collection;

import java.util.HashMap;
import java.util.Map;

public class CarHashMapDemo {

    public static void main(String[] args) {
        //汽车集合 key司机名字 value汽车对象
        Map<String,Car> cars = new HashMap<>();
        //添加数据
        cars.put("老张",new Car("001","BYD",200000,"白色"));
        cars.put("老李",new Car("002","奥迪",400000,"黑色"));
        cars.put("老赵",new Car("003","福特",150000,"红色"));
        cars.put("老刘",new Car("004","宝马",600000,"绿色"));
        //通过司机名字查找汽车
        Car car = cars.get("小赵");
        System.out.println("找到汽车：" + car);
    }
}
